home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Library / Manuels & Misc / Assembly / AOA.ZIP / CH06 / PROJ6_6.ASM < prev   
Encoding:
Assembly Source File  |  1996-02-04  |  1.8 KB  |  104 lines

  1. ; PROJ6_6.ASM-
  2. ;
  3. ; An integer input routine.
  4. ;
  5.  
  6.  
  7.  
  8. dseg        segment    para public 'data'
  9.  
  10. ; Put any variables you need here.
  11.  
  12. dseg        ends
  13.  
  14. cseg        segment    para public 'code'
  15.         assume    cs:cseg, ds:dseg
  16.  
  17.  
  18. ; GetChar is a subroutine you can call to read a single key from the
  19. ; keyboard.  It returns the character it reads in the AL register.
  20.  
  21. GetChar        proc
  22.         mov    ah, 0        ;BIOS call to read a key.
  23.         int    16h
  24.         ret
  25. GetChar        endp
  26.  
  27.  
  28.  
  29. ; PutChar prints the character in the AL register to the display.
  30.  
  31. PutChar        proc
  32.         push    ax        ;Preserve value in AH
  33.         mov    ah, 0eh        ;BIOS call to print a character.
  34.         int    10h
  35.         pop    ax        ;Restore AH's value.
  36.         ret
  37. PutChar        endp
  38.  
  39.  
  40. ; Newline-    Prints the cr/lf pair to the screen (a new line).
  41.  
  42. NewLine        proc
  43.         push    ax
  44.         mov    ax, 0e0dh    ;Carriage return
  45.         int    10h
  46.         mov    ax, 0e0ah    ;Linefeed
  47.         int    10h
  48.         pop    ax
  49.         ret
  50. NewLine        endp
  51.  
  52.  
  53.  
  54. ; Copy this routine from Project #5 (or see project five for details on
  55. ; how to write this routine if you've not done project five).
  56.  
  57. PutInt        proc
  58.         ret
  59. PutInt        endp
  60.  
  61.  
  62.  
  63. ; GetInt-    Read a sequence of characters from the keyboard.
  64. ;        As long as the characters a decimal digits, convert
  65. ;        them into an integer.  This routine should preserve
  66. ;        all registers except AX.  It should return the unsigned
  67. ;        integer in AX.
  68.  
  69. GetInt        proc
  70.         ret
  71. GetInt        endp
  72.  
  73.  
  74. ; Main program to test the PutInt routine.
  75.  
  76. Main        proc
  77.         mov    ax, dseg
  78.         mov    ds, ax
  79.  
  80.  
  81.         mov    cx, 4
  82. LoopIt:
  83.         call    GetInt
  84.         call    PutInt
  85.         call    NewLine
  86.         loop    LoopIt
  87.  
  88.  
  89.  
  90. Quit:        mov    ah, 4ch          ;DOS opcode to quit program.
  91.         int    21h        ;Call DOS.
  92. Main        endp
  93.  
  94. cseg        ends
  95.  
  96. sseg        segment    para stack 'stack'
  97. stk        byte    1024 dup ("stack   ")
  98. sseg        ends
  99.  
  100. zzzzzzseg    segment    para public 'zzzzzz'
  101. LastBytes    byte    16 dup (?)
  102. zzzzzzseg    ends
  103.         end    Main
  104.